import { log } from 'cc';
import { _decorator, Component, Node, sys, Label, native } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('DebugInfo')
export class DebugInfo extends Component {

    start() {
        let label = this.getComponent(Label);
        if (sys.isNative) {
            // label.string = `SearchPath: \n${native.fileUtils.getSearchPaths().join('\n')}`;
            let writeablePath = native.fileUtils.getWritablePath();
            // label.string = `writeablePath:\n${writeablePath}`;
            let files = native.fileUtils.listFiles(writeablePath);
            label.string = `writeablePath:\n${writeablePath}\nfiles:\n${files.join('\n')}`;
            log('@@', label.string);
            // label.string = `main.js is exist? ${native.fileUtils.isFileExist("@assets/main.js")}`;
            // label.string = native.fileUtils.getStringFromFile('@assets/assets/resources/cc.config.json');
            // label.string = native.fileUtils.fullPathForFilename('@assets/assets/resources/cc.config.json');

            // label.string =
            //     `1> main.js is exist? ${native.fileUtils.isFileExist("cc.config.json")}` + '\n' +
            //     `2> main.js is exist? ${native.fileUtils.isFileExist("assets/resources/cc.config.json")}` + '\n' +
            //     `3> main.js is exist? ${native.fileUtils.isFileExist("@assets/assets/resources/cc.config.json")}` + '\n';

            // label.string = `Is exist? ${native.fileUtils.isFileExist("values/strings.xml")}`;

        } else {
            label.string = 'Build to native to see search path.';
        }
    }

}

